#include <stdlib.h>
#include <stdio.h>
#include <sqlite3.h>

int callback(void *data,int argc,char **argv,char **clumn){
  int i = 0;
  //fprintf (stderr, "%s:\n",(char *)data);
  printf("data=%s\n",(char *)data);
  for(i=0;i<argc;i++){
     printf("%s=%s\n",clumn[i],argv[i]?argv[i]:"NULL"); 
  }
  printf("\n");                                                      
  return 0;
}

int main(){
  sqlite3 *db;
  char *errMsg;
  char *sql;
  int res = sqlite3_open ("/home/wan/mydb", &db);
  char *data = "我是传递的数据";
  if(res){
    fprintf (stderr, "打开数据库有误:%s\n",sqlite3_errmsg(db));
    exit (0);
  }
  //sprintf (sql, "update emp set name='%s',birthday='%s' where id=%d","大鹏","2003-3-3",1);
  sql = sqlite3_mprintf ("update emp set name='%Q',birthday='%s' where id=%s","大鹏","2003-3-3",1);
  printf("sql=%s\n",sql);
  res = sqlite3_exec (db, sql, callback, data, &errMsg);
  printf("res=%d\n",res);
  if(res!=SQLITE_OK){
    fprintf (stderr, "修改数据有误:%s\n",errMsg);
    sqlite3_free (errMsg);
  }
  printf("修改成功!");
  sqlite3_close (db);
  return 0;
}
